// NewImageDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Draw.h"
#include "NewImageDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNewImageDlg dialog


CNewImageDlg::CNewImageDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNewImageDlg::IDD, pParent)
	, m_bCAD(FALSE)
{
	//{{AFX_DATA_INIT(CNewImageDlg)
	m_nHeight = 0;
	m_nWidth = 0;
	//}}AFX_DATA_INIT
}


void CNewImageDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNewImageDlg)
	DDX_Control(pDX, IDC_SPINWIDTH, m_ctrlSpinWidth);
	DDX_Control(pDX, IDC_SPINHEIGHT, m_ctrlSpinHeight);
	DDX_Text(pDX, IDC_HEIGHT, m_nHeight);
	// the max height of the image is 1024
	// the min height of the image is 10
	DDV_MinMaxInt(pDX, m_nHeight, 10, 1024);
	DDX_Text(pDX, IDC_WIDTH, m_nWidth);
	// the max width of the image is 1024
	// the min width of the image is 10
	DDV_MinMaxInt(pDX, m_nWidth, 10, 1024);
	//}}AFX_DATA_MAP
	DDX_Check(pDX, IDC_CHECK_CAD, m_bCAD);
}


BEGIN_MESSAGE_MAP(CNewImageDlg, CDialog)
	//{{AFX_MSG_MAP(CNewImageDlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDOK, &CNewImageDlg::OnBnClickedOk)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNewImageDlg message handlers

BOOL CNewImageDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	// set the spin range
	m_ctrlSpinWidth.SetRange(10, 1024);
	m_ctrlSpinHeight.SetRange(10, 1024);
	
	//
	// make the dialog part transparent :
	//
	SetWindowLong(this->GetSafeHwnd(), GWL_EXSTYLE,
		GetWindowLong(this->GetSafeHwnd(), GWL_EXSTYLE) ^ 0x00000);
	HINSTANCE hInst = LoadLibrary("User32.DLL");
	if ( hInst )
	{
		typedef BOOL (WINAPI* MYFUNC) (HWND, COLORREF, BYTE, DWORD);
		MYFUNC fun = NULL;
		// get the SetLayeredWindowAttributes function pointer :
		fun = (MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
		if (fun)
			fun(this->GetSafeHwnd(), 0, 128, 2);
		FreeLibrary(hInst);
	}

	return TRUE;
}

void CNewImageDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	OnOK();
}
